package com.work.storage.controller;


import com.work.storage.service.StorageService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("storage")
public class StorageController {

    @Resource
    private StorageService storageService;

    /**
     * 减库存
     * @param commodityCode 商品代码
     * @param count 数量
     * @return
     */
    @RequestMapping(path = "/deduct")
    public Boolean deduct(String commodityCode, Integer count) {
        storageService.deduct(commodityCode, count);
        return true;
    }

    /**
     * 提供 TCC 方式扣除
     * @param commodityCode
     * @param count
     * @return
     */
    @RequestMapping(path = "/tcc/deduct")
    public Boolean tccDeduct(String commodityCode, Integer count) {
        storageService.tccDeduct(commodityCode, count);
        return true;
    }

}
